function flow=US_flow(tup,tdown,alpha,c,D)
% http://theultrasonicflowmeters.com/flowmeas-transittime.htm
% To be more precise, let's assume that Tdown is the transit-time (or time-of-flight) of a sound pulse traveling from the upstream transducer A to the downstream transducer B, and Tup is the transit-time from the opposite direction, B to A. The following equations hold:
% 
%      Tdown = ( D / sinq ) / ( c + V*cosq ),         (1)
% 
%      Tup = ( D / sinq ) / ( c - V*cosq ),              (2)
% 
% where c is the sound speed in the liquid, D is the pipe diameter and V is the flow velocity averaged over the sound path. Solving the above equations leads to
% 
%      V = ( D / sin2q ) * ?T / (Tup * Tdown),        (3)
% 
% where ?T = Tup - Tdown. Therefore, by accurately measuring the upstream and downstream transit-time Tup amd Tdown, we are able to obtain the flow velocity V. Subsequently, the flow rate is calculated as following,
% 
%      Q = K *A* V,                                              (4)

flow=D./(sind(alpha)).*(tup-tdown)/(tup.*tdown);

return